<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
<%@ include file="/common/common-css.v2.jsp"%>
<style>
#jquery-table td {
	cursor: pointer !important;
	word-break: break-all;
	word-wrap: break-word;
}

.load_bg {
	background: #000;
	opacity: 0.1;
	left: 0px;
	top: 0px;
	position: fixed;
	height: 100%;
	width: 100%;
	overflow: hidden;
	z-index: 10000;
}

.load_img {
	left: 50%;
	top: 180px;
	position: fixed;
	height: 50px;
	overflow: hidden;
	z-index: 20000;
}

a.check {
	margin-bottom: 10px;
}

@media ( min-width : 768px) and (max-width: 1200px) {
	.backup-text {
		width: 100px !important;
	}
}
</style>
</head>
<body class="no-skin">
	<div class="load_bg" style="display: none;"></div>
	<img src="http://img.tuanzidai.cn/commentloading.gif" class="load_img"
		style="display: none" />
	<div class="page-content">
		<div id="test"></div>
		<form id="queryForm">
			<div class="page-content-area">
				<div class="row">
					<div class="col-sm-12">
						<div class="widget-box"
							style="border: 0px solid #ccc; border-top: none; border-bottom: none;">
							<div class="widget-header widget-header-blue widget-header-flat">
								<h4 class="widget-title">选择条件进行查询</h4>

								<div class="widget-toolbar">
									<a href="#" data-action="collapse"> <i
										class="ace-icon fa fa-chevron-up"></i>
									</a>
								</div>
							</div>

							<div class=" widget-body">
							
								<div class="widget-main" id="condition">
								
								    <div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">平台:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select class="form-control" name="platform">
												<option value="">全部</option>
												<option value="0">通用</option>
												<option value="android">安卓</option>
												<option value="ios">ios</option>
											</select>
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">产品</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select id="prdid" name="prdid" class="form-control"></select>
										</div>
									</div>

									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">渠道</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select id="channel" name="channel"></select>
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label" style="text-align: right">订单ID:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<input type="text" name="orderId" style="width: 100%; text-align: left;">
										</div>
									</div>

									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label" 
										       style="text-align:right" >订单来源:</label>
										 <div class="col-sm-8" style="padding-left: 0;">
											<select name="type" class="form-control">
												<option value="">---请选择---</option>
												<option value="1">捷信福贷</option>
												<option value="2">宜信信贷</option>
												<option value="3">恒昌</option>
												<option value="4">小雨点网贷</option>
												<option value="6">我来贷</option>
												<option value="10">信而富</option>
												<option value="11">点融</option>
												<option value="12">小树普惠</option>
												<option value="14">51贷吧</option>
												<option value="15">中安信业</option>
												<option value="16">江湖救急</option>
												<option value="18">五号米库</option>
												<option value="19">优款</option>
												<option value="20">立借</option>
												<option value="21">万卡</option>
												<option value="22">借云</option>
												<option value="24">快来贷</option>
												<option value="25">诚信钱包</option>
												<option value="27">中腾信</option>
												<option value="28">点融魔借（新）</option>
												<option value="29">友信</option>
											</select>
										</div>
									</div>
				
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label" style="text-align: right">手机号码:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<input type="text" name="mobnum" style="width: 100%; text-align: left;">
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label" 
										       style="text-align:right" >申请状态:</label>
										 <div class="col-sm-8" style="padding-left: 0;">
											<select name="status" class="form-control">
												<option value="">---请选择---</option>
												<option value="1">订单初始化</option>
												<option value="2">验证账号失败</option>
												<option value="3">订单审核中</option>
												<option value="4">合作方取消</option>
												<option value="5">初审成功</option>
												<option value="6">申请成功</option>
												<option value="7">合作方退回</option>
												<option value="9">订单提交失败</option>
												<option value="12">合作方已放款</option>
											</select>
										</div>
									</div>

									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label" style="text-align: right"
											for="sex">申请时间:</label>
										<div class="col-sm-8" style="padding-left: 0px">
										    <div class="input-daterange input-group">
												<input type="text" data-date-format="yyyy-mm-dd"
													class="date-picker input-sm form-control"
													style="padding-left: 0px" id="startTime" name="startTime"> 
												 <span class="input-group-addon" style="width: 6px"> 
												    <i class="fa fa-exchange"></i>
												 </span>
												 <input type="text" data-date-format="yyyy-mm-dd"
													class="date-picker input-sm form-control"
													style="padding-left: 0px" id="endTime" name="endTime">
											 </div>
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3" style="clear: both;">
										<label class="col-sm-4 control-label" style="text-align: right"
											for="sex">审核时间:</label>
										<div class="col-sm-8" style="padding-left: 0px">
										    <div class="input-daterange input-group">
												<input type="text" data-date-format="yyyy-mm-dd"
													class="date-picker input-sm form-control"
													style="padding-left: 0px" id="tranStartTime" name="tranStartTime"> 
												 <span class="input-group-addon" style="width: 6px"> 
												    <i class="fa fa-exchange"></i>
												 </span>
												 <input type="text" data-date-format="yyyy-mm-dd"
													class="date-picker input-sm form-control"
													style="padding-left: 0px" id="tranEndTime" name="tranEndTime">
											 </div>
										</div>
									</div> 
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label" 
										       style="text-align:right" >订单类型:</label>
										 <div class="col-sm-8" style="padding-left: 0;">
											<select name="orderType" class="form-control">
												<option value="">---请选择---</option>
												<option value="1">站内API投递</option>
												<option value="2">一键API投递</option>
											</select>
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label" 
										       style="text-align:right" >请求环境:</label>
										 <div class="col-sm-8" style="padding-left: 0;">
											<select name="environment" class="form-control">
												<option value="">---请选择---</option>
												<option value="1">H5</option>
												<option value="2">客户端</option>
											</select>
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label" 
										       style="text-align:right" >请求来源:</label>
										 <div class="col-sm-8" style="padding-left: 0;">
											<select name="request_source" class="form-control">
												<option value="">---请选择---</option>
												<option value="1">菠萝贷</option>
												<option value="2">银河黑卡</option>
											</select>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="col-md-12 center">
						<div class="clearfix form-actions myaction">

							<button class="btn btn-purple  no-border" type="button"
								name="btn-query" onclick="query_any()">
								<i class="ace-icon fa fa-search icon-on-right bigger-110"></i>
								查询
							</button>
							&nbsp;&nbsp;&nbsp;
							<button class="btn btn-grey no-border" type="reset">
								<i class="ace-icon fa fa-undo icon-on-right bigger-110"></i> 重置
							</button>
						</div>
					</div>
				</div>
				
				<div class="row">
					<div class="col-xs-12">
					    <a href="javascript:void(0)" class="btn btn-success btn-small"
					      id="output" style="display: none;" onclick="loadlist()">导出列表</a>
						<table id="jquery-table"
							class="table table-striped table-bordered table-hover">
						</table>
					</div>
				</div>
			</div>
		</form>
	</div>
<%@ include file="/common/common-js.jsp"%>
<script type="text/javascript" src="${ctx}/js/call_func.js"></script>


<script type="text/javascript">

	function loadlist() {
		var form = document.forms["queryForm"];
		form.action = ctx + "/loanorder/exportData.action";
		form.submit();
	}
	
	//【查询】按钮Click事件
	function query_any() {
		$("#output").show();
		if(jqTable != null){
			jqTable.fnDraw();
		} else{
			loaddata();
		}
	}
    
	var jqTable = null;
	var loaddata = function() {
		jQuery(function($) {
			jqTable = $('#jquery-table').dataTable({
				//数据列控制（包括对应返回JSON属性名称，对应表头列索引位置、数据转换封装等）
				"columnDefs" : [
						{
							"title" : '订单编号',
							"targets" : [ 0 ],
							"data" : "id",
							"class" : "center",
							"bSortable" : false,
							"width" : "50px",
						},
						{
							"title" : '合作方',
							"targets" : [ 1 ],
							"data" : "type",
							"class" : "center",
							"bSortable" : false,
							"width" : "50px",
							"render": function(value, type, row) {
								switch (row.type) {
								case 1:
									var temp = "捷信福贷";
									break;
								case 2:
									var temp = "宜信信贷";
									break;
								case 3:
									var temp = "恒昌";
									break;
								case 4:
									var temp = "小雨点网贷";
									break;
								case 6:
									var temp = "我来贷";
									break;
								case 10:
									var temp = "信而富";
									break;
								case 11:
									var temp = "点融";
									break;
								case 12:
									var temp = "小树普惠";
									break;
								case 14:
									var temp = "51贷吧";
									break;
								case 15:
									var temp = "中安信业";
									break;
								case 16:
									var temp = "江湖救急";
									break;
								case 18:
									var temp = "五号米库";
									break;
								case 19:
                                     var temp = "优款";
									break;
                                case 20:
                                    var temp = "立借";
                                    break;
                                case 21:
                                    var temp = "万卡";
                                    break;
                                case 22:
                                    var temp = "借云";
                                    break;
                                case 24:
                                    var temp = "快来贷";
                                    break;
                                case 25:
                                    var temp = "诚信钱包";
                                    break;
                                case 27:
                                    var temp = "中腾信";
                                    break;
                                case 28:
                                    var temp = "点融魔借（新）";
                                    break;
                                case 29:
                                    var temp = "友信";
                                    break;
								default:
									var temp = "--";
								    break;
								}
								return temp;
							}
						},
						{
							"title" : '手机号',
							"targets" : [ 2 ],
							"data" : "mobnum",
							"class" : "center",
							"bSortable" : false,
							"width" : "50px",
						},
						{
							"title" : '申请借款金额',
							"targets" : [ 3 ],
							"data" : "amount",
							"class" : "center",
							"bSortable" : false,
							"width" : "60px",
						},
						{
							"title" : '实际放款金额',
							"targets" : [ 4 ],
							"data" : "loan_amount",
							"class" : "center",
							"bSortable" : false,
							"width" : "60px",
							"render": function(value, type, row) {
								if(value != null){
								   return value;
								} else{
								   return "--";
								}
							}
						},
						{
							"title" : '贷款期限',
							"targets" : [ 5 ],
							"data" : "peroid",
							"class" : "center",
							"bSortable" : false,
							"width" : "60px",
						},
						{
							"title" : '提交申请时间',
							"targets" : [ 6 ],
							"data" : "ctime",
							"class" : "center",
							"bSortable" : false,
							"width" : "50px",
						},
						{
							"title" : '审核时间',
							"targets" : [ 7 ],
							"data" : "transaction_time",
							"class" : "center",
							"bSortable" : false,
							"width" : "50px",
							"render": function(value, type, row) {
								if(value != null){
								   return value;
								} else{
								   return "--";
								}
							}
						},
						{
							"title" : '状态',
							"targets" : [ 8 ],
							"data" : "status",
							"class" : "center",
							"bSortable" : false,
							"width" : "50px",
							"render": function(value, type, row) {
								switch (row.status) {
								case 1:
									var temp = "订单初始化";
									break;
								case 2:
									var temp = "账号校验失败";
									break;
								case 3:
									var temp = "审核中";
									break;
								case 4:
									var temp = "合作方取消";
									break;
								case 5:
									var temp = "初审成功";
									break;
								case 6:
									var temp = "申请成功";
									break;
								case 7:
									var temp = "合作方退回";
									break;
								case 9:
									var temp = "订单提交失败";
									break;
								case 10:
									var temp = "签约失败";
									break;
								case 11:
									var temp = "验证成功";
									break;
								case 12:
									var temp = "合作方已放款";
									break;
								case 13:
									var temp = "已逾期";
									break;
								case 14:
									var temp = "宽限期内";
									break;
								case 15:
									var temp = "已结清";
									break;
								case 16:
									var temp = "已提单";
									break;
								case 17:
									var temp = "还款中";
									break;
								case 18:
									var temp = "放款失败";
									break;
								default:
									var temp = "--";
								    break;
								}
								return temp;
							}
						},
						{
							"title" : '是否授权',
							"targets" : [ 9 ],
							"data" : "authorize",
							"class" : "center",
							"bSortable" : false,
							"width" : "50px",
							"render": function(value, type, row) {
							   if(row.type == 4){
				                  if (value == 1){
				            	     return "是";
				                  } else {
				            	     return "否";
				                  }
							   } else {
								   return "--";
							   }
							}
						},
						{
							"title" : '结算金额',
							"targets" : [ 10 ],
							"data" : "settle_amount",
							"class" : "center",
							"bSortable" : false,
							"width" : "50px",
							"render": function(value, type, row) {
								if(value != null){
								   return value;
								} else{
								   return "--";
								}
							}
						},
						{
							"title" : '平台',
							"targets" : [ 11 ],
							"data" : "platform",
							"class" : "center",
							"bSortable" : false,
							"width" : "50px",
						},
						{
							"title" : '产品',
							"targets" : [ 12 ],
							"data" : "product_name",
							"class" : "center",
							"bSortable" : false,
							"width" : "50px",
							"render": function(value, type, row) {
								if(row.product_id == -1){
								   return "车主无忧";
								} else{
								   return value;
								}
							}
						},
						{
							"title" : '渠道',
							"targets" : [ 13 ],
							"data" : "channel_name",
							"class" : "center",
							"bSortable" : false,
							"width" : "50px",
						},
						{
							"title" : '订单类型',
							"targets" : [ 14 ],
							"data" : "order_type",
							"class" : "center",
							"bSortable" : false,
							"width" : "50px",
							"render": function(value, type, row) {
								if(value == 1){
								   return "站内API投递";
								} else if(value == 2){
								   return "一键API投递";
								} else {
									return "未知";
								}
							}
						},
						{
							"title" : '请求环境',
							"targets" : [ 15 ],
							"data" : "environment",
							"class" : "center",
							"bSortable" : false,
							"width" : "50px",
							"render": function(value, type, row) {
								if(value == 1){
								   return "H5";
								} else if(value == 2){
								   return "客户端";
								} else {
									return "未知";
								}
							}
						},
						{
							"title" : '请求来源',
							"targets" : [ 16 ],
							"data" : "request_source",
							"class" : "center",
							"bSortable" : false,
							"width" : "50px",
							"render": function(value, type, row) {
								if(value == 1){
								   return "菠萝贷";
								} else if(value == 2){
								   return "银河黑卡";
								} else {
									return "未知";
								}
							}
						},
						{		
			    		    "title":"操作",
			    		    "name":"userid",
			    		    "data": "userid",
			    	  	    "targets": [17], 
			    	  	    "bSortable": false,
	 		    	  	    "width": "8%",
	 		    	  	    "render": function(value, type, row) { // 返回自定义内容
	 		    	  	    	/* return "<button type='button' value='"+value+"' class='btn btn-primary btn-sm no-border infoID'>详情</button>"; */
	 		    	  	        var html = "<button type='button' value='"+value+"' class='btn btn-primary btn-sm no-border infoID'>详情</button>";
	 		    	  	            html += "&nbsp;<button type='button' class='btn btn-primary btn-sm no-border' onclick= 'getRequestJson("+ row.id +", "+ row.type +")'>请求/返回</button>";
	 		    	  	        return html;   
		                    }
			    	    },
				 ],
				 "sAjaxSource": ctx + "/loanorder/list.action?rand=" + Math.random(),//数据源URL
				 "fnServerData" : function(sSource, aoData,fnCallback) {
					  var data = $('#queryForm').serializeObject();
					  data.aoData = JSON.stringify(aoData);
					  $.ajax({
							"type" : "POST",
							"dataType" : 'json',
							"url" : sSource,
							"data" : data,
							"success" : function(resp) {
								fnCallback(resp);
								initListPage();
							},
							"error" : function(XMLHttpRequest,
									textStatus, errorThrown) {
							},
							"complete" : function() {
								$(".load_bg,.load_img").hide();
							}
						});
				},
				"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
	  				//=====================这里实现行双击事件======================//
	  				$(nRow).on('click', 'td .infoID', function (index) {
	  					var id = $(this).val();
						var url = "/loanuser/getinfo.action?userid=" + id;
						url = encodeURI(url);
						openDialogWithRand(url,900,996,"",function(data){
							query_any();
						});
				     });
	  			},
				"sScrollXInner" : "100%",
				"sScrollY" : "100%",//如果不设置，IE会有问题
				"aaSorting" : [ [ 0, "asc" ] ] //初始化加载，默认按第几列排序、排序方式（列从0开始计算）
			});
		});
	}
	
	//时间控件
	jQuery(function($) {
		$(".date-picker").datepicker({
			autoclose : true
		}).next().on(ace.click_event, function() {
			$(this).prev().focus();
		});
	});
	
	function getRequestJson(id,type){
		var url = "/loanorder/request.jsp?order_id=" + id + "&type=" + type;
		url = encodeURI(url);
		openDialogWithRand(url,1050,556,"",function(data){});
	}
	
	$(document).ready(function(){
		loadChannel();
		loadProduct();
		$("#channel").combobox();
	});
</script>

</body>
</html>